// 从环境变量中获取配置
const getEnvConfig = () => {
	// 开发环境检测
	const isDevelopment = process.env.NODE_ENV === 'development' || 
						 process.env.MODE === 'development' ||
						 process.env.DEV === 'true';
	
	return {
		// 接口地址
		apiUrl: process.env.VITE_API_URL || 'https://api.yummall.cn',
		// ws接口服务
		wsUrl: process.env.VITE_WS_URL || 'wss://api.yummall.cn',
		// AI流式访问地址
		wsChatPath: process.env.VITE_WS_CHAT_PATH || '/ws-anno/chat.ws',
		moke: process.env.VITE_OPEN_MOKE || 'true',
		// 环境标识
		isDevelopment
	}
}

// 获取环境配置
const envConfig = getEnvConfig();

const baseConfig = {
	// 接口地址
	apiUrl: envConfig.apiUrl,
	wsUrl: envConfig.wsUrl,
	//AI流式访问地址
	wsChatPath: envConfig.wsChatPath,
	moke: envConfig.moke,
	// 百度语音识别 https://vop.baidu.com/pro_api
	// 通过后端接口包裹，可以避免h5端跨域跨域问题
	baiduAudioUrl: envConfig.apiUrl + '/cms/aiDialogueHistory/VoiceToText',
	// 请求接口加载状态
	custom: {
		//加载中开关
		loading: process.env.VITE_LOADING_ENABLED === 'true',
		//相应错误提示开关
		toast: process.env.VITE_TOAST_ENABLED === 'true',
		// 超时时间
		timeout: parseInt(process.env.VITE_REQUEST_TIMEOUT) || 60000
	},
	// token鉴权
	getToken: () => uni.getStorageSync("bytToken"),
	// 环境信息
	env: {
		isDevelopment: envConfig.isDevelopment,
		mode: process.env.MODE
	}
};

// 开源连接配置
export default baseConfig;